package com.example.extest;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class ActivityRadio extends Activity {

	// @Override
		public void onCreate(Bundle state) {
			super.onCreate(state);
			setContentView(R.layout.radio_layout);
			showRadioSelected();
		}
		
		public void showRadioSelected(){
			final RadioGroup rdGroup = (RadioGroup)findViewById(R.id.radioGroup1);
			Button btnDisplay = (Button)findViewById(R.id.btnDisplay);
			
			btnDisplay.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					int selectedID = rdGroup.getCheckedRadioButtonId();
					
					RadioButton rdSelected = (RadioButton)findViewById(selectedID);
					
					Toast.makeText(ActivityRadio.this, "Item: "+rdSelected.getText(),Toast.LENGTH_SHORT).show();
				}
			});
		}
}
